<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
      <el-form-item label="店铺名称" prop="shopName">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入店铺名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="consumeList">
      <el-table-column label="店铺名称" align="center" prop="shopName"  width="160" :show-overflow-tooltip="true"/>
      <el-table-column label="首页推荐" align="center" prop="homePage"  width="120" :show-overflow-tooltip="true"/>
      <el-table-column label="分类推荐" align="center" prop="classification"  width="120" :show-overflow-tooltip="true"/>
      <el-table-column label="搜索推荐" align="center" prop="search"  width="120" :show-overflow-tooltip="true"/>
      <el-table-column label="带货推荐" align="center" prop="instation"  width="120" :show-overflow-tooltip="true"/>
      <el-table-column label="站外推荐" align="center" prop="outside" width="120" :show-overflow-tooltip="true"/>
      <el-table-column label="海外推荐" align="center" prop="overseas" width="120" :show-overflow-tooltip="true"/>
      <el-table-column label="剩余" align="center" prop="residue" width="120" :show-overflow-tooltip="true"/>
<!--      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['car:consume:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['car:consume:remove']"
          >删除</el-button>
        </template>
      </el-table-column>-->
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listConsume, getConsume,} from "@/api/store/storeFlowHistory";

export default {
  name: "Consume",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 店铺流量消耗表格数据
      consumeList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name:null,
        id:null,
      },
    };
  },
  created() {
    if(this.$route.query.shopId){
      this.queryParams.id = this.$route.query.shopId || null;
    }
    this.getList();
  },
  methods: {
    /** 查询店铺流量消耗列表 */
    getList() {
      this.loading = true;
      listConsume(this.queryParams).then(response => {
        this.consumeList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams= {
        pageNum: 1,
          pageSize: 10,
      };
      this.handleQuery();
    },
  }
};
</script>
